package workflow.element {
import flash.events.MouseEvent;

import spark.components.BorderContainer;

import workflow.event.AdjustElementEvent;
import workflow.skin.ElementAdjusterSkin;

public class ElementAdjuster extends BorderContainer {
	
	private var _adjusting:Boolean;

	public function ElementAdjuster() {
		super();

		setStyle("skinClass", Class(ElementAdjusterSkin));

		addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
		addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
	}

	private function mouseMoveHandler(e:MouseEvent):void {
		if (e.buttonDown) {
			_adjusting = true;
			dispatchEvent(new AdjustElementEvent(AdjustElementEvent.BEGIN));
		}
	}

	private function mouseUpHandler(e:MouseEvent):void {
		if (_adjusting) {
			_adjusting = false;
			dispatchEvent(new AdjustElementEvent(AdjustElementEvent.END));
		}
	}

}
}
